package cn.wbnyua.msm.web.api;

import cn.wbnyua.msm.util.JsonResponse;
import cn.wbnyua.msm.web.domain.Goods;
import cn.wbnyua.msm.web.domain.Member;
import cn.wbnyua.msm.web.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 作者：wbnyua.
 * 创建时间: 2023/2/8 22:58.
 */

@RestController
@RequestMapping("/api/member")
public class MemberApi {

    @Autowired
    private MemberService service;

    @GetMapping
    public JsonResponse<List<Member>> list(){
        return new JsonResponse<>(service.findAll());
    }

    @PostMapping
    public JsonResponse<String> add(Member member){
        service.add(member);
        return JsonResponse.success();
    }

    @PutMapping
    public JsonResponse<String> update(Member member){
        service.update(member);
        return JsonResponse.success();
    }

    @DeleteMapping
    public JsonResponse<String> remove(Long id){
        service.remove(id);
        return JsonResponse.success();
    }

}
